import java.util.Random;
import java.util.Scanner;

public class Test {
    //逻辑控制与方法
    //猜数字游戏
    public static void main(String[] args) {
        Random random = new Random();
        //int randNum = random.nextInt(100);//[0~100)
        //int randNum = random.nextInt(100)+100;//[0~200]
        int randNum = random.nextInt(50)+50;//[50~100]
        //Math.random()
    }

    public static void main24(String[] args) {
        Scanner scan = new Scanner(System.in);
        Random random = new Random();
        int randNum = random.nextInt(100);
        //System.out.println(randNum);
        while(true){
            System.out.println("请输入你要猜的数字：");
            int num = scan.nextInt();
            if(num > randNum){
                System.out.println("你猜大了");
            }else if(num == randNum){
                System.out.println("你猜对了");
                break;
            }else{
                System.out.println("猜小了");
            }
        }

    }

    public static void main23(String[] args) {
        Scanner scan = new Scanner(System.in);

        while(scan.hasNextInt()){
            int n = scan.nextInt();
            System.out.println("n = "+n);
        }
    }

    public static void main22(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入年龄：");
        int n = scan.nextInt();
        System.out.println(n);

        scan.nextLine();

        //此时，上边输入完后，回车，会被下边读取到
        System.out.println("请输入姓名：");
        String name = scan.nextLine();
        System.out.println(name);
    }

    public static void main21(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入姓名：");
        //遇到空格就结束了 空格后的获取不到
        String name = scan.nextLine();
        System.out.println(name);

        String name2 = scan.next();
        System.out.println(name2);

        System.out.println("请输入年龄：");
        int n = scan.nextInt();
        System.out.println(n);

        System.out.println("请输入你的工资：");
        float f = scan.nextFloat();
        System.out.println(f);
    }

    public static void main20(String[] args) {
        System.out.println("输出且换行");
        System.out.print("输出不换行");
        System.out.printf("%s\n","格式化输出，和c语言一样");
    }

    public static void main19(String[] args) {
        int i = 0;
        do{
            System.out.println(i);
            i++;
        }while(i <= 10);
    }

    public static void main18(String[] args) {
        for(int i = 0; ;i++){
            //当中间条件为空时，for循环为死循环
            System.out.println("sasa");
        }
    }

    public static void main17(String[] args) {
        int sum = 0;
        for(int k = 0;k <= 6;k++){
            int ret = 1;
            for(int i = 1;i <= k;i++){
                ret *= i;
            }
            sum += ret;
        }
        System.out.println(sum);
    }

    public static void main16(String[] args) {
        for(int i = 0;i < 10;i++){
            System.out.println(i);
        }
    }

    public static void main15(String[] args) {
        //找到1~100内既能被三整除，也能别五整除的
        int a = 1;
        while(a <= 100){
            if(a % 3 == 0 && a % 5 == 0) {
                System.out.println(a);
            }
            a++;
            continue;
        }

    }

    public static void main14(String[] args) {
        //死循环
        while(true){
            System.out.println("hello");
        }
    }

    public static void main13(String[] args) {
        int i = 1;
        int sum = 0;
        while (i <= 5){
            int a = 1;
            int ret = 1;
            while (a <= i){
                ret *= a;
                a++;
        }
             sum += ret;
             i++;
        }
        System.out.println(sum);
    }

    public static void main12(String[] args) {
        int a = 1;
        int sum = 1;
        while (a <= 5){
            sum *= a;
            a++;
        }
        System.out.println(sum);
    }

    public static void main11(String[] args) {
        int a = 1;
        int sum = 0;
        while (a <= 100){
            sum = sum + a;
            a++;
        }
        System.out.println(sum);
        System.out.println("================");
        a = 1;
        int sumDdd = 0;
        while (a <= 100){
            sumDdd += a;
            a += 2;
        }
        System.out.println(sumDdd);
        System.out.println("==================");
        a = 2;
        int sumEve = 0;
        while (a <= 100){
            sumEve += a;
            a += 2;
        }
        System.out.println(sumEve);
    }

    public static void main10(String[] args) {
        int a = 1;
        /*while(布尔表达式) {

        }*/
        while(a <= 10){
            System.out.println(a);
            a++;

        }
    }

    public static void main9(String[] args) {
        //不能做switch的参数的数据类型是什么？
        //long double float boolean

        int a = 10;
        switch(a) {
            case 1:
                System.out.println("1");
                break;
            case 2:
                System.out.println("2");
                break;
            case 3:
                System.out.println("3");
            default:
                System.out.println("输入有误");
                break;
        }
    }

    public static void main8(String[] args) {
        int year = 2020;
        if( year % 400 ==0 || (year % 100 != 0 && year % 4 == 0)) {
            System.out.println(year + "是闰年");
        }else{
            System.out.println(year + "不是闰年");
        }
    }

    public static void main7(String[] args) {
        int year = 2020;
        if(year % 100 == 0 && year % 400 ==0 || year % 100 == 0 && year % 4 == 0) {
            System.out.println(year + "是闰年");
        }else{
            System.out.println(year + "不是闰年");
        }
    }

    public static void main6(String[] args) {
        int year = 2022;
        if(year % 100 == 0) {
            if(year % 400 == 0) {
                System.out.println(year + "是闰年");
            }else{
                System.out.println(year + "不是闰年");
            }
        }else {
            if(year % 4 == 0) {
                System.out.println(year + "是闰年");
            }else {
                System.out.println(year + "不是闰年");
            }
        }
    }

    public static void main5(String[] args) {
        int a = 10;
        if(a > 0) {
            System.out.println("是正数 ");
        }else if(a < 0) {
            System.out.println("是负数 ");
        }else {
            System.out.println("0! ");
        }
    }

    public static void main4(String[] args) {
        int a = 10;
        if(a % 2 != 0){
            System.out.println("是奇数");
        }else{
            System.out.println("是偶数");
        }
    }

    public static void main3(String[] args) {
        int a = 10;
        if(a < 10){

        }else if(a > 15){

        }else{

        }
    }

    public static void main2(String[] args) {
        int a = 10;
        if(a == 10){
            System.out.println("a == 10");
        }else{
            System.out.println("a != 10");
        }
    }

    public static void main1(String[] args){
        //&&  ||  ! 需要与布尔表达式搭配

        System.out.println("1");
        System.out.println("2");
        System.out.println("3");

        System.out.println();
    }
}
